/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DataStructures;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 *
 * @author Manuel
 */
public class ProjectInformation {

    private String name;
    private String url;
    private String description;
    private Date lastRelease;
    //date for jaxb in string
    private String lsDate;
    private int forge;
    private ArrayList<String> labels;
    private ArrayList<String> languages;
    private ArrayList<String[]> collaborators;
    private int activity;
    private int repositoryType;
    private int bugTracker;
    private ProjectPackage archieve;
    private String bugLink;
    private String repositoryLink;
    private String chosenLanguage;

    public ProjectInformation(){
        labels = new ArrayList<String>();
        languages = new ArrayList<String>();
        collaborators = new ArrayList<String[]>();
    }


    public void addCollaboratorIfNew(String c, String mail){
        boolean exists = false;
        for(int i = 0;i<collaborators.size();i++){
            if(collaborators.get(i)[0].equals(c) || collaborators.get(i)[1].equals(mail))
                exists = true;
        }
        if(!exists && c != null && mail != null){
            String[] newCollab = new String[2];
            newCollab[0] =c;
            newCollab[1] =mail;
            collaborators.add(newCollab);

        }
        else if(!exists)
            System.out.println("NOT INSERTING COLLABORATOR COLLAB[0] =" +c+ "  COLLAB[1] ="+mail);
    }

    public String[] getCollaborator(int pos){
        return collaborators.get(pos);
    }

    public int getCollaboratorNo(){
        return collaborators.size();
    }

    public void addLabel(String l){
        labels.add(l.toLowerCase());
    }

    public String getMainLanguage() {
        boolean result = false;
        String correctLanguage = "";
        for(int i = (this.languages.size()-1);i>=0;i--){
            if(languages.get(i).contains("java")){
                correctLanguage = "java";
            }
            else if(languages.get(i).contains("cplusplus")){
                correctLanguage = "cplusplus";
            }
        }
        return correctLanguage;
    }

    public void addLanguage(String language) {
        this.languages.add(language.toLowerCase());
    }

    public int getActivity() {
        return activity;
    }

    public void setActivity(int activity) {
        this.activity = activity;
    }

    public int getBugTracker() {
        return bugTracker;
    }

    public void setBugTracker(int bugTracker) {
        this.bugTracker = bugTracker;
    }

    public int getForge() {
        return forge;
    }

    public void setForge(int forge) {
        this.forge = forge;
    }

    public int getRepositoryType() {
        return repositoryType;
    }

    public void setRepositoryType(int repositoryType) {
        this.repositoryType = repositoryType;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ProjectPackage getArchieveLink() {
        return archieve;
    }

    public void setArchieveLink(ProjectPackage archieveLink) {
        this.archieve = archieveLink;
    }

    public String getRepositoryLink() {
        return repositoryLink;
    }

    public void setRepositoryLink(String repositoryLink) {
        this.repositoryLink = repositoryLink;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getBugLink() {
        return bugLink;
    }

    public void setBugLink(String bugLink) {
        this.bugLink = bugLink;
    }

    public ArrayList<String[]> getCollaborators() {
        return collaborators;
    }

    public void setCollaborators(ArrayList<String[]> collaborators) {
        this.collaborators = collaborators;
    }

    public ArrayList<String> getLabels() {
        return labels;
    }

    public void setLabels(ArrayList<String> labels) {
        this.labels = labels;
    }



     public void printInformation(){
            System.out.print(
                    "\n\n\nProject: "+this.name+"\nDescription:"+this.description+
                    "\nRepository:"+this.repositoryLink+"\nArchieve:"+this.archieve.getName()+
                    "\nActivity:"+this.activity+"\nCollaborators:"



                    );for(int i = 0;i<this.collaborators.size();i++){
                        System.out.print(collaborators.get(i)+",");
                    }
            System.out.print("\nLabels: ");
            for(int i = 0;i<this.labels.size();i++){
                        System.out.print(labels.get(i)+",");
                    }
            System.out.print("\nLanguages: ");
            for(int i = 0;i<this.languages.size();i++){
                        System.out.print(languages.get(i)+",");
                    }

        }

    public void setLanguageChosen(String lang) {
        this.chosenLanguage = lang;
    }

    public String getLanguageChosen(){
        return chosenLanguage;
    }

    public Date getLastRelease() {
        return lastRelease;
    }

    public void setLastRelease(Date d) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
            this.lastRelease = d;
            this.lsDate = sdf.format(d);
    }

    public String getLsDate() {
        return lsDate;
    }

}
